<template>
  <div></div>
</template>

<script setup lang="ts">
  import { ref, onMounted, computed } from 'vue'
  import { useTagsViewStore } from '@/store/modules/tagsView.ts'
  import { useRoute, useRouter } from 'vue-router'
  import pageComponentName from '@/config/page-component-name'

  defineOptions({
    name: pageComponentName.shop.shoppingManager,
  })

  const TagsViewStore = useTagsViewStore()
  const visitedViews = computed(() => TagsViewStore.visitedViews)
  const route = useRoute()
  const router = useRouter()
  const url = ref(
    'https://yxtk.zhxlfd.com/login?token=7JJnJxMBNvVBXkPhyCwja_mxfqRARAsQLcUI3mLwr8Cbf7v8hRcQOIjUFv328Z53rHgevQas4r6Pf1e',
  )
  onMounted(async () => {
    if (isActive(route.path)) {
      toLastView()
    }
    window.open(url.value, '_blank')
  })
  const isActive = (path) => {
    return path === route.path
  }
  function toLastView() {
    const nextTab = visitedViews.value[visitedViews.value.length - 1]
    if (!nextTab) return
    router.push(nextTab.path)
    TagsViewStore.addVisitedView(nextTab)
  }
</script>
<style lang="scss"></style>
